// pages/mine/mine.js
// pages/message/message.js
import config from "../../../api/config";
const mixins = require('../../../mixins/user')
const common = require('../../../mixins/common')
var a, e, app = getApp();
let interstitialAd =null;
const options = {
  goto: function(){
    wx.navigateTo({
      url: '/pages/mine/editmine/editmine',
    })
  },
  /**
   * 页面的初始数据
   */
  data: {
   
    showFavAppTip: true,
    userBannerStyle: "",
    advert:app.globalData.advert,
    tabbar: config.tarbar,
    petInfoList: [{
      url: "/pages/mine/release/release",
      pic: "/image/fabu.png",
      text: "我的动态",
      clickEvent:"navUrl",

    },
    //  {
    //   url: "/pages/mine/posts/posts",
    //   pic: "/image/jihua.png",
    //   text: "我的文章",
    //   clickEvent:"navUrl",
    // },
     {
      url: "/pages/mine/sign/sign",
      pic: "/image/sign.png",
      text: "签到",
      clickEvent:"navUrl"
    }, {
      url: "/pages/myAdoption/myAdoption",
      pic: "/image/dingyue.png",
      text: "订阅更新",
      clickEvent:"tapSubscribe"
    }],
    toolList: [
      // {
      //   url: "/pages/diary/diarylist",
      //   pic: "/image/riqian.png",
      //   text: "日签记录",
      //   marker: !1
      // }, 
      {
        url: "/pages/shop/exchanges",
        pic: "/image/dingdan.png",
        text: "我的订单",
        marker: !1
      }, {
        url: "/pages/mine/likeList/likeList",
        pic: "/image/dianzan.png",
        text: "我的点赞",
        marker: !1
      },
      {
        url: "/pages/mine/favList/favList",
        pic: "/image/shoucang.png",
        text: "我的收藏",
        marker: !1
      }
    ],
    indexAdList: [{
        "id": 120,
        "url": "/image/mine2.png",
        "link": "/pages/guanyu/qun/qun",
        "title": "微信群"
      },
      {
        "id": 121,
        "url": "/image/mine1.png",
        "link": "/pages/shopshare/shopshare",
        // "redirectUrl": "#",
        "title": "关于我们"
      }
      // {
      //   "id": 127,
      //   "url": "/image/mine3.png",
      //   "link": "/pages/diary/diary",
      //   "redirectUrl": "#",
      //   "title": "日签记录"
      // }
    ],
    currentConfig: {
      show: false,
      transition: true,
      zIndex: 99,
      locked: false,
      direction: 'bottom',
      arcRadius: 18,
      maxHeight: 600,
      minHeight: 600,
      opacity: 0.4
    },
    isMine: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (wx.createInterstitialAd&&this.data.advert.interstitialAd) {
      interstitialAd = wx.createInterstitialAd({
        adUnitId: this.data.advert.interstitialAd
      })
      interstitialAd.onLoad(() => {})
      interstitialAd.onError((err) => {})
      interstitialAd.onClose(() => {})
    }
    let navBarHeight = this.getNavbarHeight();
    this.setData({
      navBarHeight: navBarHeight
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    if (interstitialAd) {
      interstitialAd.show().catch((err) => {
        console.error(err)
      })
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    "function" == typeof this.getTabBar && this.getTabBar() && this.getTabBar().setData({
      selected: 4
  })
    let that = this;
    let user = app.globalData.user
    if (!user) {
      user = '';
      wx.navigateTo({
        url: '/pages/login/login',
      })
    } else {
      this.getUserMineInfo()
    }

  },

  isIos: function () {
    return wx.getSystemInfoSync().system.toLowerCase().includes("ios");
  },
  isIpx: function () {
    return this.isIos() && this.getStatusBarHeight() > 40;
  },
  getStatusBarHeight: function () {
    return wx.getSystemInfoSync().statusBarHeight;
  },
  getNavbarHeight: function () {
    return this.rpx2px(this.isIos() ? 88 : 96) + this.getStatusBarHeight();
  },
  rpx2px: function (t) {
    var e = this.getWindowWidth() / 750;
    return parseFloat((t * e).toPrecision(12), 10);
  },

  getWindowWidth: function () {
    return wx.getSystemInfoSync().windowWidth;
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  navUrl:function(e){
    let url=e.currentTarget.dataset.url;
    let userid=e.currentTarget.dataset.userid;
    wx.navigateTo({
      url: url+'?id='+userid,
    })

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  onPageScroll: function (t) {
    var e = t.scrollTop > 0;
    if (this.isIos() && !e) {
      var n = 1 + Math.abs(t.scrollTop) / 150;
      this.setData({
        userBannerStyle: "position: fixed; transform-origin: top center; transform: scale(".concat(n, ")")
      });
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
}


mixins(options)
common(options)
Page(options)